<?php
  require_once("../includes/config.php"); 
    //make sure the person in authorized
  if ($_SESSION["r"]>1)
  {
  	$_SESSION['error_message'] = "غير مسموح";
	redirect("index.php");
	die();
  }
 // $users= query('SELECT * FROM apartments_owner WHERE id= ?',$_SESSION['user_id']);
 // $user_types= query('SELECT * FROM roles WHERE id= ?',$users[0]['role']);
  if ($_SESSION['r']==0)
  {
 $users= query("SELECT * FROM apartments_owner LEFT JOIN roles ON apartments_owner.role=roles.id WHERE (apartments_owner.role=? || apartments_owner.role=? || apartments_owner.id=?)",0,1,$_SESSION['id']);
	}
	elseif ($_SESSION['r']==1)
	{
	$users= query("SELECT * FROM apartments_owner LEFT JOIN roles ON apartments_owner.role=roles.id WHERE apartments_owner.id=? AND apartments_owner.role!='0' AND apartments_owner.role!='1'",$_SESSION['id']);
	}
  render("settings/usersManage.php", array("title"=>"إدارة المستخدمين","users"=>$users));
?>